<template>

  姓名：
  <el-input v-model="adminuser.name" style="width: 240px" placeholder="Please input"/>
  手机号：
  <el-input v-model="adminuser.phone_number" style="width: 240px" placeholder="Please input"/>
  入职时间：
  <el-date-picker
      v-model="adminuser.entry_date"
      type="date"
      placeholder="Pick a date"
      style="width: 100%"
  />
  角色：
  <el-select v-model="adminuser.role" placeholder="请选择角色">
    <el-option v-for="(item,key) in rolelist" :key="key" :label="item.role_name" :value="item.id"/>
  </el-select>

  <el-button @click="add">添加</el-button>

</template>
<script setup>
import axios from "axios";
import {ref, onMounted} from "vue";
import {useRouter} from "vue-router";

let router = useRouter()
let adminuser = ref({})
let rolelist = ref([])

const findrole = () => {
  axios.get('http://localhost:8000/tadmin/ad/').then(res => {
    rolelist.value = res.data
  })
}

const add = () => {
  axios.get('http://localhost:8000/tadmin/users/', adminuser.value).then(res => {
    router.push('/adminuser')
  })
}

onMounted(() => {
  findrole()
})

</script>
<style scoped>


</style>